<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 8.6.8" />
<title>git-p4(1)</title>
<style type="text/css">
/* Shared CSS for AsciiDoc xhtml11 and html5 backends */

/* Default font. */
body {
  font-family: Georgia,serif;
}

/* Title font. */
h1, h2, h3, h4, h5, h6,
div.title, caption.title,
thead, p.table.header,
#toctitle,
#author, #revnumber, #revdate, #revremark,
#footer {
  font-family: Arial,Helvetica,sans-serif;
}

body {
  margin: 1em 5% 1em 5%;
}

a {
  color: blue;
  text-decoration: underline;
}
a:visited {
  color: fuchsia;
}

em {
  font-style: italic;
  color: navy;
}

strong {
  font-weight: bold;
  color: #083194;
}

h1, h2, h3, h4, h5, h6 {
  color: #527bbd;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

h1, h2, h3 {
  border-bottom: 2px solid silver;
}
h2 {
  padding-top: 0.5em;
}
h3 {
  float: left;
}
h3 + * {
  clear: left;
}
h5 {
  font-size: 1.0em;
}

div.sectionbody {
  margin-left: 0;
}

hr {
  border: 1px solid silver;
}

p {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

ul, ol, li > p {
  margin-top: 0;
}
ul > li     { color: #aaa; }
ul > li > * { color: black; }

.monospaced, code, pre {
  font-family: "Courier New", Courier, monospace;
  font-size: inherit;
  color: navy;
  padding: 0;
  margin: 0;
}


#author {
  color: #527bbd;
  font-weight: bold;
  font-size: 1.1em;
}
#email {
}
#revnumber, #revdate, #revremark {
}

#footer {
  font-size: small;
  border-top: 2px solid silver;
  padding-top: 0.5em;
  margin-top: 4.0em;
}
#footer-text {
  float: left;
  padding-bottom: 0.5em;
}
#footer-badges {
  float: right;
  padding-bottom: 0.5em;
}

#preamble {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}
div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
div.admonitionblock {
  margin-top: 2.0em;
  margin-bottom: 2.0em;
  margin-right: 10%;
  color: #606060;
}

div.content { /* Block element content. */
  padding: 0;
}

/* Block element titles. */
div.title, caption.title {
  color: #527bbd;
  font-weight: bold;
  text-align: left;
  margin-top: 1.0em;
  margin-bottom: 0.5em;
}
div.title + * {
  margin-top: 0;
}

td div.title:first-child {
  margin-top: 0.0em;
}
div.content div.title:first-child {
  margin-top: 0.0em;
}
div.content + div.title {
  margin-top: 0.0em;
}

div.sidebarblock > div.content {
  background: #ffffee;
  border: 1px solid #dddddd;
  border-left: 4px solid #f0f0f0;
  padding: 0.5em;
}

div.listingblock > div.content {
  border: 1px solid #dddddd;
  border-left: 5px solid #f0f0f0;
  background: #f8f8f8;
  padding: 0.5em;
}

div.quoteblock, div.verseblock {
  padding-left: 1.0em;
  margin-left: 1.0em;
  margin-right: 10%;
  border-left: 5px solid #f0f0f0;
  color: #888;
}

div.quoteblock > div.attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock > pre.content {
  font-family: inherit;
  font-size: inherit;
}
div.verseblock > div.attribution {
  padding-top: 0.75em;
  text-align: left;
}
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
div.verseblock + div.attribution {
  text-align: left;
}

div.admonitionblock .icon {
  vertical-align: top;
  font-size: 1.1em;
  font-weight: bold;
  text-decoration: underline;
  color: #527bbd;
  padding-right: 0.5em;
}
div.admonitionblock td.content {
  padding-left: 0.5em;
  border-left: 3px solid #dddddd;
}

div.exampleblock > div.content {
  border-left: 3px solid #dddddd;
  padding-left: 0.5em;
}

div.imageblock div.content { padding-left: 0; }
span.image img { border-style: none; }
a.image:visited { color: white; }

dl {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
dt {
  margin-top: 0.5em;
  margin-bottom: 0;
  font-style: normal;
  color: navy;
}
dd > *:first-child {
  margin-top: 0.1em;
}

ul, ol {
    list-style-position: outside;
}
ol.arabic {
  list-style-type: decimal;
}
ol.loweralpha {
  list-style-type: lower-alpha;
}
ol.upperalpha {
  list-style-type: upper-alpha;
}
ol.lowerroman {
  list-style-type: lower-roman;
}
ol.upperroman {
  list-style-type: upper-roman;
}

div.compact ul, div.compact ol,
div.compact p, div.compact p,
div.compact div, div.compact div {
  margin-top: 0.1em;
  margin-bottom: 0.1em;
}

tfoot {
  font-weight: bold;
}
td > div.verse {
  white-space: pre;
}

div.hdlist {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
div.hdlist tr {
  padding-bottom: 15px;
}
dt.hdlist1.strong, td.hdlist1.strong {
  font-weight: bold;
}
td.hdlist1 {
  vertical-align: top;
  font-style: normal;
  padding-right: 0.8em;
  color: navy;
}
td.hdlist2 {
  vertical-align: top;
}
div.hdlist.compact tr {
  margin: 0;
  padding-bottom: 0;
}

.comment {
  background: yellow;
}

.footnote, .footnoteref {
  font-size: 0.8em;
}

span.footnote, span.footnoteref {
  vertical-align: super;
}

#footnotes {
  margin: 20px 0 20px 0;
  padding: 7px 0 0 0;
}

#footnotes div.footnote {
  margin: 0 0 5px 0;
}

#footnotes hr {
  border: none;
  border-top: 1px solid silver;
  height: 1px;
  text-align: left;
  margin-left: 0;
  width: 20%;
  min-width: 100px;
}

div.colist td {
  padding-right: 0.5em;
  padding-bottom: 0.3em;
  vertical-align: top;
}
div.colist td img {
  margin-top: 0.3em;
}

@media print {
  #footer-badges { display: none; }
}

#toc {
  margin-bottom: 2.5em;
}

#toctitle {
  color: #527bbd;
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 1.0em;
  margin-bottom: 0.1em;
}

div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
  margin-top: 0;
  margin-bottom: 0;
}
div.toclevel2 {
  margin-left: 2em;
  font-size: 0.9em;
}
div.toclevel3 {
  margin-left: 4em;
  font-size: 0.9em;
}
div.toclevel4 {
  margin-left: 6em;
  font-size: 0.9em;
}

span.aqua { color: aqua; }
span.black { color: black; }
span.blue { color: blue; }
span.fuchsia { color: fuchsia; }
span.gray { color: gray; }
span.green { color: green; }
span.lime { color: lime; }
span.maroon { color: maroon; }
span.navy { color: navy; }
span.olive { color: olive; }
span.purple { color: purple; }
span.red { color: red; }
span.silver { color: silver; }
span.teal { color: teal; }
span.white { color: white; }
span.yellow { color: yellow; }

span.aqua-background { background: aqua; }
span.black-background { background: black; }
span.blue-background { background: blue; }
span.fuchsia-background { background: fuchsia; }
span.gray-background { background: gray; }
span.green-background { background: green; }
span.lime-background { background: lime; }
span.maroon-background { background: maroon; }
span.navy-background { background: navy; }
span.olive-background { background: olive; }
span.purple-background { background: purple; }
span.red-background { background: red; }
span.silver-background { background: silver; }
span.teal-background { background: teal; }
span.white-background { background: white; }
span.yellow-background { background: yellow; }

span.big { font-size: 2em; }
span.small { font-size: 0.6em; }

span.underline { text-decoration: underline; }
span.overline { text-decoration: overline; }
span.line-through { text-decoration: line-through; }

div.unbreakable { page-break-inside: avoid; }


/*
 * xhtml11 specific
 *
 * */

div.tableblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
div.tableblock > table {
  border: 3px solid #527bbd;
}
thead, p.table.header {
  font-weight: bold;
  color: #527bbd;
}
p.table {
  margin-top: 0;
}
/* Because the table frame attribute is overriden by CSS in most browsers. */
div.tableblock > table[frame="void"] {
  border-style: none;
}
div.tableblock > table[frame="hsides"] {
  border-left-style: none;
  border-right-style: none;
}
div.tableblock > table[frame="vsides"] {
  border-top-style: none;
  border-bottom-style: none;
}


/*
 * html5 specific
 *
 * */

table.tableblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
thead, p.tableblock.header {
  font-weight: bold;
  color: #527bbd;
}
p.tableblock {
  margin-top: 0;
}
table.tableblock {
  border-width: 3px;
  border-spacing: 0px;
  border-style: solid;
  border-color: #527bbd;
  border-collapse: collapse;
}
th.tableblock, td.tableblock {
  border-width: 1px;
  padding: 4px;
  border-style: solid;
  border-color: #527bbd;
}

table.tableblock.frame-topbot {
  border-left-style: hidden;
  border-right-style: hidden;
}
table.tableblock.frame-sides {
  border-top-style: hidden;
  border-bottom-style: hidden;
}
table.tableblock.frame-none {
  border-style: hidden;
}

th.tableblock.halign-left, td.tableblock.halign-left {
  text-align: left;
}
th.tableblock.halign-center, td.tableblock.halign-center {
  text-align: center;
}
th.tableblock.halign-right, td.tableblock.halign-right {
  text-align: right;
}

th.tableblock.valign-top, td.tableblock.valign-top {
  vertical-align: top;
}
th.tableblock.valign-middle, td.tableblock.valign-middle {
  vertical-align: middle;
}
th.tableblock.valign-bottom, td.tableblock.valign-bottom {
  vertical-align: bottom;
}


/*
 * manpage specific
 *
 * */

body.manpage h1 {
  padding-top: 0.5em;
  padding-bottom: 0.5em;
  border-top: 2px solid silver;
  border-bottom: 2px solid silver;
}
body.manpage h2 {
  border-style: none;
}
body.manpage div.sectionbody {
  margin-left: 3em;
}

@media print {
  body.manpage div#toc { display: none; }
}


</style>
<script type="text/javascript">
/*<![CDATA[*/
var asciidoc = {  // Namespace.

/////////////////////////////////////////////////////////////////////
// Table Of Contents generator
/////////////////////////////////////////////////////////////////////

/* Author: Mihai Bazon, September 2002
 * http://students.infoiasi.ro/~mishoo
 *
 * Table Of Content generator
 * Version: 0.4
 *
 * Feel free to use this script under the terms of the GNU General Public
 * License, as long as you do not remove or alter this notice.
 */

 /* modified by Troy D. Hanson, September 2006. License: GPL */
 /* modified by Stuart Rackham, 2006, 2009. License: GPL */

// toclevels = 1..4.
toc: function (toclevels) {

  function getText(el) {
    var text = "";
    for (var i = el.firstChild; i != null; i = i.nextSibling) {
      if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
        text += i.data;
      else if (i.firstChild != null)
        text += getText(i);
    }
    return text;
  }

  function TocEntry(el, text, toclevel) {
    this.element = el;
    this.text = text;
    this.toclevel = toclevel;
  }

  function tocEntries(el, toclevels) {
    var result = new Array;
    var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
    // Function that scans the DOM tree for header elements (the DOM2
    // nodeIterator API would be a better technique but not supported by all
    // browsers).
    var iterate = function (el) {
      for (var i = el.firstChild; i != null; i = i.nextSibling) {
        if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
          var mo = re.exec(i.tagName);
          if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
            result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
          }
          iterate(i);
        }
      }
    }
    iterate(el);
    return result;
  }

  var toc = document.getElementById("toc");
  if (!toc) {
    return;
  }

  // Delete existing TOC entries in case we're reloading the TOC.
  var tocEntriesToRemove = [];
  var i;
  for (i = 0; i < toc.childNodes.length; i++) {
    var entry = toc.childNodes[i];
    if (entry.nodeName.toLowerCase() == 'div'
     && entry.getAttribute("class")
     && entry.getAttribute("class").match(/^toclevel/))
      tocEntriesToRemove.push(entry);
  }
  for (i = 0; i < tocEntriesToRemove.length; i++) {
    toc.removeChild(tocEntriesToRemove[i]);
  }

  // Rebuild TOC entries.
  var entries = tocEntries(document.getElementById("content"), toclevels);
  for (var i = 0; i < entries.length; ++i) {
    var entry = entries[i];
    if (entry.element.id == "")
      entry.element.id = "_toc_" + i;
    var a = document.createElement("a");
    a.href = "#" + entry.element.id;
    a.appendChild(document.createTextNode(entry.text));
    var div = document.createElement("div");
    div.appendChild(a);
    div.className = "toclevel" + entry.toclevel;
    toc.appendChild(div);
  }
  if (entries.length == 0)
    toc.parentNode.removeChild(toc);
},


/////////////////////////////////////////////////////////////////////
// Footnotes generator
/////////////////////////////////////////////////////////////////////

/* Based on footnote generation code from:
 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
 */

footnotes: function () {
  // Delete existing footnote entries in case we're reloading the footnodes.
  var i;
  var noteholder = document.getElementById("footnotes");
  if (!noteholder) {
    return;
  }
  var entriesToRemove = [];
  for (i = 0; i < noteholder.childNodes.length; i++) {
    var entry = noteholder.childNodes[i];
    if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
      entriesToRemove.push(entry);
  }
  for (i = 0; i < entriesToRemove.length; i++) {
    noteholder.removeChild(entriesToRemove[i]);
  }

  // Rebuild footnote entries.
  var cont = document.getElementById("content");
  var spans = cont.getElementsByTagName("span");
  var refs = {};
  var n = 0;
  for (i=0; i<spans.length; i++) {
    if (spans[i].className == "footnote") {
      n++;
      var note = spans[i].getAttribute("data-note");
      if (!note) {
        // Use [\s\S] in place of . so multi-line matches work.
        // Because JavaScript has no s (dotall) regex flag.
        note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
        spans[i].innerHTML =
          "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
          "' title='View footnote' class='footnote'>" + n + "</a>]";
        spans[i].setAttribute("data-note", note);
      }
      noteholder.innerHTML +=
        "<div class='footnote' id='_footnote_" + n + "'>" +
        "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
        n + "</a>. " + note + "</div>";
      var id =spans[i].getAttribute("id");
      if (id != null) refs["#"+id] = n;
    }
  }
  if (n == 0)
    noteholder.parentNode.removeChild(noteholder);
  else {
    // Process footnoterefs.
    for (i=0; i<spans.length; i++) {
      if (spans[i].className == "footnoteref") {
        var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
        href = href.match(/#.*/)[0];  // Because IE return full URL.
        n = refs[href];
        spans[i].innerHTML =
          "[<a href='#_footnote_" + n +
          "' title='View footnote' class='footnote'>" + n + "</a>]";
      }
    }
  }
},

install: function(toclevels) {
  var timerId;

  function reinstall() {
    asciidoc.footnotes();
    if (toclevels) {
      asciidoc.toc(toclevels);
    }
  }

  function reinstallAndRemoveTimer() {
    clearInterval(timerId);
    reinstall();
  }

  timerId = setInterval(reinstall, 500);
  if (document.addEventListener)
    document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
  else
    window.onload = reinstallAndRemoveTimer;
}

}
asciidoc.install();
/*]]>*/
</script>
</head>
<body class="manpage">
<div id="header">
<h1>
git-p4(1) Manual Page
</h1>
<h2>NAME</h2>
<div class="sectionbody">
<p>git-p4 -
   Import from and submit to Perforce repositories
</p>
</div>
</div>
<div id="content">
<div class="sect1">
<h2 id="_synopsis">SYNOPSIS</h2>
<div class="sectionbody">
<div class="verseblock">
<pre class="content"><em>git p4 clone</em> [&lt;sync options&gt;] [&lt;clone options&gt;] &lt;p4 depot path&gt;&#8230;
<em>git p4 sync</em> [&lt;sync options&gt;] [&lt;p4 depot path&gt;&#8230;]
<em>git p4 rebase</em>
<em>git p4 submit</em> [&lt;submit options&gt;] [&lt;master branch name&gt;]</pre>
<div class="attribution">
</div></div>
</div>
</div>
<div class="sect1">
<h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph"><p>This command provides a way to interact with p4 repositories
using Git.</p></div>
<div class="paragraph"><p>Create a new Git repository from an existing p4 repository using
<em>git p4 clone</em>, giving it one or more p4 depot paths.  Incorporate
new commits from p4 changes with <em>git p4 sync</em>.  The <em>sync</em> command
is also used to include new branches from other p4 depot paths.
Submit Git changes back to p4 using <em>git p4 submit</em>.  The command
<em>git p4 rebase</em> does a sync plus rebases the current branch onto
the updated p4 remote branch.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_example">EXAMPLE</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
Clone a repository:
</p>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 clone //depot/path/project</code></pre>
</div></div>
</li>
<li>
<p>
Do some work in the newly created Git repository:
</p>
<div class="listingblock">
<div class="content">
<pre><code>$ cd project
$ vi foo.h
$ git commit -a -m "edited foo.h"</code></pre>
</div></div>
</li>
<li>
<p>
Update the Git repository with recent changes from p4, rebasing your
  work on top:
</p>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 rebase</code></pre>
</div></div>
</li>
<li>
<p>
Submit your commits back to p4:
</p>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 submit</code></pre>
</div></div>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
<h2 id="_commands">COMMANDS</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_clone">Clone</h3>
<div class="paragraph"><p>Generally, <em>git p4 clone</em> is used to create a new Git directory
from an existing p4 repository:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 clone //depot/path/project</code></pre>
</div></div>
<div class="paragraph"><p>This:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
Creates an empty Git repository in a subdirectory called <em>project</em>.
</p>
</li>
<li>
<p>
Imports the full contents of the head revision from the given p4
depot path into a single commit in the Git branch <em>refs/remotes/p4/master</em>.
</p>
</li>
<li>
<p>
Creates a local branch, <em>master</em> from this remote and checks it out.
</p>
</li>
</ol></div>
<div class="paragraph"><p>To reproduce the entire p4 history in Git, use the <em>@all</em> modifier on
the depot path:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 clone //depot/path/project@all</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_sync">Sync</h3>
<div class="paragraph"><p>As development continues in the p4 repository, those changes can
be included in the Git repository using:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 sync</code></pre>
</div></div>
<div class="paragraph"><p>This command finds new changes in p4 and imports them as Git commits.</p></div>
<div class="paragraph"><p>P4 repositories can be added to an existing Git repository using
<em>git p4 sync</em> too:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ mkdir repo-git
$ cd repo-git
$ git init
$ git p4 sync //path/in/your/perforce/depot</code></pre>
</div></div>
<div class="paragraph"><p>This imports the specified depot into
<em>refs/remotes/p4/master</em> in an existing Git repository.  The
<em>--branch</em> option can be used to specify a different branch to
be used for the p4 content.</p></div>
<div class="paragraph"><p>If a Git repository includes branches <em>refs/remotes/origin/p4</em>, these
will be fetched and consulted first during a <em>git p4 sync</em>.  Since
importing directly from p4 is considerably slower than pulling changes
from a Git remote, this can be useful in a multi-developer environment.</p></div>
<div class="paragraph"><p>If there are multiple branches, doing <em>git p4 sync</em> will automatically
use the "BRANCH DETECTION" algorithm to try to partition new changes
into the right branch.  This can be overridden with the <em>--branch</em>
option to specify just a single branch to update.</p></div>
</div>
<div class="sect2">
<h3 id="_rebase">Rebase</h3>
<div class="paragraph"><p>A common working pattern is to fetch the latest changes from the p4 depot
and merge them with local uncommitted changes.  Often, the p4 repository
is the ultimate location for all code, thus a rebase workflow makes
sense.  This command does <em>git p4 sync</em> followed by <em>git rebase</em> to move
local commits on top of updated p4 changes.</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 rebase</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_submit">Submit</h3>
<div class="paragraph"><p>Submitting changes from a Git repository back to the p4 repository
requires a separate p4 client workspace.  This should be specified
using the <em>P4CLIENT</em> environment variable or the Git configuration
variable <em>git-p4.client</em>.  The p4 client must exist, but the client root
will be created and populated if it does not already exist.</p></div>
<div class="paragraph"><p>To submit all changes that are in the current Git branch but not in
the <em>p4/master</em> branch, use:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 submit</code></pre>
</div></div>
<div class="paragraph"><p>To specify a branch other than the current one, use:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git p4 submit topicbranch</code></pre>
</div></div>
<div class="paragraph"><p>The upstream reference is generally <em>refs/remotes/p4/master</em>, but can
be overridden using the <em>--origin=</em> command-line option.</p></div>
<div class="paragraph"><p>The p4 changes will be created as the user invoking <em>git p4 submit</em>. The
<em>--preserve-user</em> option will cause ownership to be modified
according to the author of the Git commit.  This option requires admin
privileges in p4, which can be granted using <em>p4 protect</em>.</p></div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_options">OPTIONS</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_general_options">General options</h3>
<div class="paragraph"><p>All commands except clone accept these options.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--git-dir &lt;dir&gt;
</dt>
<dd>
<p>
        Set the <em>GIT_DIR</em> environment variable.  See <a href="git.html">git(1)</a>.
</p>
</dd>
<dt class="hdlist1">
--verbose, -v
</dt>
<dd>
<p>
        Provide more progress information.
</p>
</dd>
</dl></div>
</div>
<div class="sect2">
<h3 id="_sync_options">Sync options</h3>
<div class="paragraph"><p>These options can be used in the initial <em>clone</em> as well as in
subsequent <em>sync</em> operations.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--branch &lt;ref&gt;
</dt>
<dd>
<p>
        Import changes into &lt;ref&gt; instead of refs/remotes/p4/master.
        If &lt;ref&gt; starts with refs/, it is used as is.  Otherwise, if
        it does not start with p4/, that prefix is added.
</p>
<div class="paragraph"><p>By default a &lt;ref&gt; not starting with refs/ is treated as the
name of a remote-tracking branch (under refs/remotes/).  This
behavior can be modified using the --import-local option.</p></div>
<div class="paragraph"><p>The default &lt;ref&gt; is "master".</p></div>
<div class="paragraph"><p>This example imports a new remote "p4/proj2" into an existing
Git repository:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>    $ git init
    $ git p4 sync --branch=refs/remotes/p4/proj2 //depot/proj2</code></pre>
</div></div>
</dd>
<dt class="hdlist1">
--detect-branches
</dt>
<dd>
<p>
        Use the branch detection algorithm to find new paths in p4.  It is
        documented below in "BRANCH DETECTION".
</p>
</dd>
<dt class="hdlist1">
--changesfile &lt;file&gt;
</dt>
<dd>
<p>
        Import exactly the p4 change numbers listed in <em>file</em>, one per
        line.  Normally, <em>git p4</em> inspects the current p4 repository
        state and detects the changes it should import.
</p>
</dd>
<dt class="hdlist1">
--silent
</dt>
<dd>
<p>
        Do not print any progress information.
</p>
</dd>
<dt class="hdlist1">
--detect-labels
</dt>
<dd>
<p>
        Query p4 for labels associated with the depot paths, and add
        them as tags in Git. Limited usefulness as only imports labels
        associated with new changelists. Deprecated.
</p>
</dd>
<dt class="hdlist1">
--import-labels
</dt>
<dd>
<p>
        Import labels from p4 into Git.
</p>
</dd>
<dt class="hdlist1">
--import-local
</dt>
<dd>
<p>
        By default, p4 branches are stored in <em>refs/remotes/p4/</em>,
        where they will be treated as remote-tracking branches by
        <a href="git-branch.html">git-branch(1)</a> and other commands.  This option instead
        puts p4 branches in <em>refs/heads/p4/</em>.  Note that future
        sync operations must specify <em>--import-local</em> as well so that
        they can find the p4 branches in refs/heads.
</p>
</dd>
<dt class="hdlist1">
--max-changes &lt;n&gt;
</dt>
<dd>
<p>
        Limit the number of imported changes to <em>n</em>.  Useful to
        limit the amount of history when using the <em>@all</em> p4 revision
        specifier.
</p>
</dd>
<dt class="hdlist1">
--keep-path
</dt>
<dd>
<p>
        The mapping of file names from the p4 depot path to Git, by
        default, involves removing the entire depot path.  With this
        option, the full p4 depot path is retained in Git.  For example,
        path <em>//depot/main/foo/bar.c</em>, when imported from
        <em>//depot/main/</em>, becomes <em>foo/bar.c</em>.  With <em>--keep-path</em>, the
        Git path is instead <em>depot/main/foo/bar.c</em>.
</p>
</dd>
<dt class="hdlist1">
--use-client-spec
</dt>
<dd>
<p>
        Use a client spec to find the list of interesting files in p4.
        See the "CLIENT SPEC" section below.
</p>
</dd>
</dl></div>
</div>
<div class="sect2">
<h3 id="_clone_options">Clone options</h3>
<div class="paragraph"><p>These options can be used in an initial <em>clone</em>, along with the <em>sync</em>
options described above.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--destination &lt;directory&gt;
</dt>
<dd>
<p>
        Where to create the Git repository.  If not provided, the last
        component in the p4 depot path is used to create a new
        directory.
</p>
</dd>
<dt class="hdlist1">
--bare
</dt>
<dd>
<p>
        Perform a bare clone.  See <a href="git-clone.html">git-clone(1)</a>.
</p>
</dd>
<dt class="hdlist1">
-/ &lt;path&gt;
</dt>
<dd>
<p>
        Exclude selected depot paths when cloning.
</p>
</dd>
</dl></div>
</div>
<div class="sect2">
<h3 id="_submit_options">Submit options</h3>
<div class="paragraph"><p>These options can be used to modify <em>git p4 submit</em> behavior.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--origin &lt;commit&gt;
</dt>
<dd>
<p>
        Upstream location from which commits are identified to submit to
        p4.  By default, this is the most recent p4 commit reachable
        from <em>HEAD</em>.
</p>
</dd>
<dt class="hdlist1">
-M
</dt>
<dd>
<p>
        Detect renames.  See <a href="git-diff.html">git-diff(1)</a>.  Renames will be
        represented in p4 using explicit <em>move</em> operations.  There
        is no corresponding option to detect copies, but there are
        variables for both moves and copies.
</p>
</dd>
<dt class="hdlist1">
--preserve-user
</dt>
<dd>
<p>
        Re-author p4 changes before submitting to p4.  This option
        requires p4 admin privileges.
</p>
</dd>
<dt class="hdlist1">
--export-labels
</dt>
<dd>
<p>
        Export tags from Git as p4 labels. Tags found in Git are applied
        to the perforce working directory.
</p>
</dd>
<dt class="hdlist1">
--dry-run, -n
</dt>
<dd>
<p>
        Show just what commits would be submitted to p4; do not change
        state in Git or p4.
</p>
</dd>
<dt class="hdlist1">
--prepare-p4-only
</dt>
<dd>
<p>
        Apply a commit to the p4 workspace, opening, adding and deleting
        files in p4 as for a normal submit operation.  Do not issue the
        final "p4 submit", but instead print a message about how to
        submit manually or revert.  This option always stops after the
        first (oldest) commit.  Git tags are not exported to p4.
</p>
</dd>
<dt class="hdlist1">
--conflict=(ask|skip|quit)
</dt>
<dd>
<p>
        Conflicts can occur when applying a commit to p4.  When this
        happens, the default behavior ("ask") is to prompt whether to
        skip this commit and continue, or quit.  This option can be used
        to bypass the prompt, causing conflicting commits to be automatically
        skipped, or to quit trying to apply commits, without prompting.
</p>
</dd>
<dt class="hdlist1">
--branch &lt;branch&gt;
</dt>
<dd>
<p>
        After submitting, sync this named branch instead of the default
        p4/master.  See the "Sync options" section above for more
        information.
</p>
</dd>
</dl></div>
</div>
<div class="sect2">
<h3 id="_rebase_options">Rebase options</h3>
<div class="paragraph"><p>These options can be used to modify <em>git p4 rebase</em> behavior.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--import-labels
</dt>
<dd>
<p>
        Import p4 labels.
</p>
</dd>
</dl></div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_depot_path_syntax">DEPOT PATH SYNTAX</h2>
<div class="sectionbody">
<div class="paragraph"><p>The p4 depot path argument to <em>git p4 sync</em> and <em>git p4 clone</em> can
be one or more space-separated p4 depot paths, with an optional
p4 revision specifier on the end:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
"//depot/my/project"
</dt>
<dd>
<p>
    Import one commit with all files in the <em>#head</em> change under that tree.
</p>
</dd>
<dt class="hdlist1">
"//depot/my/project@all"
</dt>
<dd>
<p>
    Import one commit for each change in the history of that depot path.
</p>
</dd>
<dt class="hdlist1">
"//depot/my/project@1,6"
</dt>
<dd>
<p>
    Import only changes 1 through 6.
</p>
</dd>
<dt class="hdlist1">
"//depot/proj1@all //depot/proj2@all"
</dt>
<dd>
<p>
    Import all changes from both named depot paths into a single
    repository.  Only files below these directories are included.
    There is not a subdirectory in Git for each "proj1" and "proj2".
    You must use the <em>--destination</em> option when specifying more
    than one depot path.  The revision specifier must be specified
    identically on each depot path.  If there are files in the
    depot paths with the same name, the path with the most recently
    updated version of the file is the one that appears in Git.
</p>
</dd>
</dl></div>
<div class="paragraph"><p>See <em>p4 help revisions</em> for the full syntax of p4 revision specifiers.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_client_spec">CLIENT SPEC</h2>
<div class="sectionbody">
<div class="paragraph"><p>The p4 client specification is maintained with the <em>p4 client</em> command
and contains among other fields, a View that specifies how the depot
is mapped into the client repository.  The <em>clone</em> and <em>sync</em> commands
can consult the client spec when given the <em>--use-client-spec</em> option or
when the useClientSpec variable is true.  After <em>git p4 clone</em>, the
useClientSpec variable is automatically set in the repository
configuration file.  This allows future <em>git p4 submit</em> commands to
work properly; the submit command looks only at the variable and does
not have a command-line option.</p></div>
<div class="paragraph"><p>The full syntax for a p4 view is documented in <em>p4 help views</em>.  <em>git p4</em>
knows only a subset of the view syntax.  It understands multi-line
mappings, overlays with <em>+</em>, exclusions with <em>-</em> and double-quotes
around whitespace.  Of the possible wildcards, <em>git p4</em> only handles
<em>&#8230;</em>, and only when it is at the end of the path.  <em>git p4</em> will complain
if it encounters an unhandled wildcard.</p></div>
<div class="paragraph"><p>Bugs in the implementation of overlap mappings exist.  If multiple depot
paths map through overlays to the same location in the repository,
<em>git p4</em> can choose the wrong one.  This is hard to solve without
dedicating a client spec just for <em>git p4</em>.</p></div>
<div class="paragraph"><p>The name of the client can be given to <em>git p4</em> in multiple ways.  The
variable <em>git-p4.client</em> takes precedence if it exists.  Otherwise,
normal p4 mechanisms of determining the client are used:  environment
variable P4CLIENT, a file referenced by P4CONFIG, or the local host name.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_branch_detection">BRANCH DETECTION</h2>
<div class="sectionbody">
<div class="paragraph"><p>P4 does not have the same concept of a branch as Git.  Instead,
p4 organizes its content as a directory tree, where by convention
different logical branches are in different locations in the tree.
The <em>p4 branch</em> command is used to maintain mappings between
different areas in the tree, and indicate related content.  <em>git p4</em>
can use these mappings to determine branch relationships.</p></div>
<div class="paragraph"><p>If you have a repository where all the branches of interest exist as
subdirectories of a single depot path, you can use <em>--detect-branches</em>
when cloning or syncing to have <em>git p4</em> automatically find
subdirectories in p4, and to generate these as branches in Git.</p></div>
<div class="paragraph"><p>For example, if the P4 repository structure is:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>//depot/main/...
//depot/branch1/...</code></pre>
</div></div>
<div class="paragraph"><p>And "p4 branch -o branch1" shows a View line that looks like:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>//depot/main/... //depot/branch1/...</code></pre>
</div></div>
<div class="paragraph"><p>Then this <em>git p4 clone</em> command:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>git p4 clone --detect-branches //depot@all</code></pre>
</div></div>
<div class="paragraph"><p>produces a separate branch in <em>refs/remotes/p4/</em> for //depot/main,
called <em>master</em>, and one for //depot/branch1 called <em>depot/branch1</em>.</p></div>
<div class="paragraph"><p>However, it is not necessary to create branches in p4 to be able to use
them like branches.  Because it is difficult to infer branch
relationships automatically, a Git configuration setting
<em>git-p4.branchList</em> can be used to explicitly identify branch
relationships.  It is a list of "source:destination" pairs, like a
simple p4 branch specification, where the "source" and "destination" are
the path elements in the p4 repository.  The example above relied on the
presence of the p4 branch.  Without p4 branches, the same result will
occur with:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>git init depot
cd depot
git config git-p4.branchList main:branch1
git p4 clone --detect-branches //depot@all .</code></pre>
</div></div>
</div>
</div>
<div class="sect1">
<h2 id="_performance">PERFORMANCE</h2>
<div class="sectionbody">
<div class="paragraph"><p>The fast-import mechanism used by <em>git p4</em> creates one pack file for
each invocation of <em>git p4 sync</em>.  Normally, Git garbage compression
(<a href="git-gc.html">git-gc(1)</a>) automatically compresses these to fewer pack files,
but explicit invocation of <em>git repack -adf</em> may improve performance.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_configuration_variables">CONFIGURATION VARIABLES</h2>
<div class="sectionbody">
<div class="paragraph"><p>The following config settings can be used to modify <em>git p4</em> behavior.
They all are in the <em>git-p4</em> section.</p></div>
<div class="sect2">
<h3 id="_general_variables">General variables</h3>
<div class="dlist"><dl>
<dt class="hdlist1">
git-p4.user
</dt>
<dd>
<p>
        User specified as an option to all p4 commands, with <em>-u &lt;user&gt;</em>.
        The environment variable <em>P4USER</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.password
</dt>
<dd>
<p>
        Password specified as an option to all p4 commands, with
        <em>-P &lt;password&gt;</em>.
        The environment variable <em>P4PASS</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.port
</dt>
<dd>
<p>
        Port specified as an option to all p4 commands, with
        <em>-p &lt;port&gt;</em>.
        The environment variable <em>P4PORT</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.host
</dt>
<dd>
<p>
        Host specified as an option to all p4 commands, with
        <em>-h &lt;host&gt;</em>.
        The environment variable <em>P4HOST</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.client
</dt>
<dd>
<p>
        Client specified as an option to all p4 commands, with
        <em>-c &lt;client&gt;</em>, including the client spec.
</p>
</dd>
</dl></div>
</div>
<div class="sect2">
<h3 id="_clone_and_sync_variables">Clone and sync variables</h3>
<div class="dlist"><dl>
<dt class="hdlist1">
git-p4.syncFromOrigin
</dt>
<dd>
<p>
        Because importing commits from other Git repositories is much faster
        than importing them from p4, a mechanism exists to find p4 changes
        first in Git remotes.  If branches exist under <em>refs/remote/origin/p4</em>,
        those will be fetched and used when syncing from p4.  This
        variable can be set to <em>false</em> to disable this behavior.
</p>
</dd>
<dt class="hdlist1">
git-p4.branchUser
</dt>
<dd>
<p>
        One phase in branch detection involves looking at p4 branches
        to find new ones to import.  By default, all branches are
        inspected.  This option limits the search to just those owned
        by the single user named in the variable.
</p>
</dd>
<dt class="hdlist1">
git-p4.branchList
</dt>
<dd>
<p>
        List of branches to be imported when branch detection is
        enabled.  Each entry should be a pair of branch names separated
        by a colon (:).  This example declares that both branchA and
        branchB were created from main:
</p>
<div class="listingblock">
<div class="content">
<pre><code>git config       git-p4.branchList main:branchA
git config --add git-p4.branchList main:branchB</code></pre>
</div></div>
</dd>
<dt class="hdlist1">
git-p4.ignoredP4Labels
</dt>
<dd>
<p>
        List of p4 labels to ignore. This is built automatically as
        unimportable labels are discovered.
</p>
</dd>
<dt class="hdlist1">
git-p4.importLabels
</dt>
<dd>
<p>
        Import p4 labels into git, as per --import-labels.
</p>
</dd>
<dt class="hdlist1">
git-p4.labelImportRegexp
</dt>
<dd>
<p>
        Only p4 labels matching this regular expression will be imported. The
        default value is <em>[a-zA-Z0-9_\-.]+$</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.useClientSpec
</dt>
<dd>
<p>
        Specify that the p4 client spec should be used to identify p4
        depot paths of interest.  This is equivalent to specifying the
        option <em>--use-client-spec</em>.  See the "CLIENT SPEC" section above.
        This variable is a boolean, not the name of a p4 client.
</p>
</dd>
</dl></div>
</div>
<div class="sect2">
<h3 id="_submit_variables">Submit variables</h3>
<div class="dlist"><dl>
<dt class="hdlist1">
git-p4.detectRenames
</dt>
<dd>
<p>
        Detect renames.  See <a href="git-diff.html">git-diff(1)</a>.  This can be true,
        false, or a score as expected by <em>git diff -M</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.detectCopies
</dt>
<dd>
<p>
        Detect copies.  See <a href="git-diff.html">git-diff(1)</a>.  This can be true,
        false, or a score as expected by <em>git diff -C</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.detectCopiesHarder
</dt>
<dd>
<p>
        Detect copies harder.  See <a href="git-diff.html">git-diff(1)</a>.  A boolean.
</p>
</dd>
<dt class="hdlist1">
git-p4.preserveUser
</dt>
<dd>
<p>
        On submit, re-author changes to reflect the Git author,
        regardless of who invokes <em>git p4 submit</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.allowMissingP4Users
</dt>
<dd>
<p>
        When <em>preserveUser</em> is true, <em>git p4</em> normally dies if it
        cannot find an author in the p4 user map.  This setting
        submits the change regardless.
</p>
</dd>
<dt class="hdlist1">
git-p4.skipSubmitEdit
</dt>
<dd>
<p>
        The submit process invokes the editor before each p4 change
        is submitted.  If this setting is true, though, the editing
        step is skipped.
</p>
</dd>
<dt class="hdlist1">
git-p4.skipSubmitEditCheck
</dt>
<dd>
<p>
        After editing the p4 change message, <em>git p4</em> makes sure that
        the description really was changed by looking at the file
        modification time.  This option disables that test.
</p>
</dd>
<dt class="hdlist1">
git-p4.allowSubmit
</dt>
<dd>
<p>
        By default, any branch can be used as the source for a <em>git p4
        submit</em> operation.  This configuration variable, if set, permits only
        the named branches to be used as submit sources.  Branch names
        must be the short names (no "refs/heads/"), and should be
        separated by commas (","), with no spaces.
</p>
</dd>
<dt class="hdlist1">
git-p4.skipUserNameCheck
</dt>
<dd>
<p>
        If the user running <em>git p4 submit</em> does not exist in the p4
        user map, <em>git p4</em> exits.  This option can be used to force
        submission regardless.
</p>
</dd>
<dt class="hdlist1">
git-p4.attemptRCSCleanup
</dt>
<dd>
<p>
        If enabled, <em>git p4 submit</em> will attempt to cleanup RCS keywords
        ($Header$, etc). These would otherwise cause merge conflicts and prevent
        the submit going ahead. This option should be considered experimental at
        present.
</p>
</dd>
<dt class="hdlist1">
git-p4.exportLabels
</dt>
<dd>
<p>
        Export Git tags to p4 labels, as per --export-labels.
</p>
</dd>
<dt class="hdlist1">
git-p4.labelExportRegexp
</dt>
<dd>
<p>
        Only p4 labels matching this regular expression will be exported. The
        default value is <em>[a-zA-Z0-9_\-.]+$</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.conflict
</dt>
<dd>
<p>
        Specify submit behavior when a conflict with p4 is found, as per
        --conflict.  The default behavior is <em>ask</em>.
</p>
</dd>
</dl></div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_implementation_details">IMPLEMENTATION DETAILS</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
Changesets from p4 are imported using Git fast-import.
</p>
</li>
<li>
<p>
Cloning or syncing does not require a p4 client; file contents are
  collected using <em>p4 print</em>.
</p>
</li>
<li>
<p>
Submitting requires a p4 client, which is not in the same location
  as the Git repository.  Patches are applied, one at a time, to
  this p4 client and submitted from there.
</p>
</li>
<li>
<p>
Each commit imported by <em>git p4</em> has a line at the end of the log
  message indicating the p4 depot location and change number.  This
  line is used by later <em>git p4 sync</em> operations to know which p4
  changes are new.
</p>
</li>
</ul></div>
</div>
</div>
</div>
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
Last updated 2013-08-20 08:40:27 PDT
</div>
</div>
</body>
</html>
